class: center, middle, inverse, title-slide .title[ #
Causal Diagrams
] .author[ ### Christoph Hanck ] .date[ ### Summer 2023 ] --- layout: true <a style="position: absolute;top:5px;left:10px;color:#004c93;" target="Overview" href="https://kaslides.netlify.app/">
</a> --- ## Motivation Before going into all the technicalities of causality, we need to understand *why* we should worry so much about causality: **many interesting research questions are causal in nature.** <br> .blockquote[ ### Examples: Economic research questions - We don’t want to know if countries with higher minimum wages have less poverty, we want to know if raising the minimum wage reduces poverty. - We don’t want to know if people who take a popular common-cold-shortening medicine get better, we want to know if the medicine made them get better more quickly. - We don’t want to know if the central bank cutting interest rates was shortly followed by a recession, we want to know if the interest rate cut caused the recession. ] --- ## So what is causality? .vcenter[ .blockquote[ ### Definition: Causality We say that `\(X\)` causes `\(Y\)` when we interfere and change the value of `\(X\)` without changing anything else, then the distribution of `\(Y\)` would also change as a result. ]] --- ## Causality — Examples .vcenter[ .blockquote[ ### Examples: a few causal relationships Obvious ones: - A light switch being set to on causes the light to be on - Setting off fireworks raises the noise level Less obvious ones: - Getting a college degree increases your earnings - Tariffs reduce the amount of trade ]] --- ## Causality **Correlation does not imply causality.** Often we observe non-zero correlations that do not reflect causal relationships (or may be causal in the wrong direction!) .blockquote[ ### Examples: Causality vs. correlation Obvious ones: - People tend to wear shorts on days when ice cream trucks are out - Rooster crowing sounds are followed closely by sunrise Less obvious ones: - Colds tend to clear up a few days after you take Emergen-C - The performance of the economy tends to be lower or higher depending on the president’s political party ] --- ## Causality Not all `\(Y\)` must be due to `\(X\)`: we still say `\(X\)` causes `\(Y\)` even if changing `\(X\)` does not always change `\(Y\)`, but just changes the distribution of `\(Y\)`: the **probability** that `\(Y\)` occurs. <br> .blockquote[ ### Example: Switches and bulbs Flipping a light switch ( `\(X\)` ) on alters the distribution of the light coming on ( `\(Y\)` ), but not that it happens for certain: - The bulb may be broken - The bulb may be loose - There may be no electricity ] --- ## Weasel words There are lots of words that are generally taken to imply causality, as well as words that describe relationships *without* implying causality. There are also some “weasel words” that don’t technically say anything about causality but clearly want you to hear it. <br> .center[What are some of these words?] </br> We can say `\(X\)` causes `\(Y\)` by saying: - `\(X\)` causes `\(Y\)` ("Many studies suggest that eating chocolate causes weight gain") - `\(X\)` affects `\(Y\)` ("Various factors affect the success of a business") - The effect of `\(X\)` on `\(Y\)` ("The effect of social media on mental health is thought to be significant") - `\(X\)` influences `\(Y\)` (T"he effect of diet influences overall health") --- ## Why are Weasel words important? - Knowing these terms can help interpreting what scientific studies are really saying, and when someone might be trying to be misleading: Weasel terms are problematic because they convey that there is a relation between `\(X\)` and `\(Y\)` (from `\(X\)` to `\(Y\)`), without literally claiming a causal relationship. - Clearly non-causal terms do not even specify which of `\(X\)` and `\(Y\)` goes first! They just talk about these two variables and how they work together. - Causal phrases always have a clear direction. They further tell us *what* `\(X\)` is doing to `\(Y\)`. .footnote[ The key is that all the weasel phrases are equally true if you swap the positions of X and Y, even though swapping them would really change how we’d interpret the claim. “Aspirin is linked to headaches” is no more or less true than “Headaches are linked to aspirin.” You can hear the notion that aspirin causes your headache in the first one, which is false. You can get away with it without technically lying because it’s true that they’re “linked.” ] --- exclude: true ## The Problem of causal inference **Potential outcomes** Meet Angela with health status `\(Y\)` and consider the variable `$$\begin{equation*} X = \begin{cases}1, \ \text{person gets medical treatment}\\ 0, \ \text{else.} \end{cases} \end{equation*}$$` - We we would like to check Angela’s `\(Y\)` when choosing `\(X=0\)` and also check what Angela’s `\(Y\)` is again when we make `\(X=1\)`. If the two `\(Y\)`'s are different, then we can say that `\(X\)` causes `\(Y\)`. - However, Angela cannot exist both with `\(X=0\)` and with `\(X=1\)`. She either got that medical treatment or she did not! - Let’s say she did. So for Angela, X=1 and, let’s say, Y=10. The other one, what Y would have been if we made X=0, is missing. We don’t know what it is! Could also be Y=10. Could be Y=9. Could be Y=1000! --- exclude: true ## A possible solution! - We can take someone who actually DOES have X=0 and compare their Y? - However, as both of them are different people, it is quite natural that they will have different Y BESIDES X. - So if we find someone, Gareth, with X=0 and they have Y=9, is that because X increases Y, or is that just because Angela and Gareth would have had different Ys anyway? - In order to overcome with this problem, and making as good a guess as possible as to what that Y would have been if X had been different, we want to think about two people/firms/countries that are basically **exactly the same** except that one has X=0 and one has X=1 </br> --- exclude: true ## Potential outcomes <br> The logic we just went through is the basis of the potential outcomes model, which is one way of thinking about causality. </br> <br> Figuring out that makes a good counterfactual estimate is a key part of causal inference! </br> .footnote[ counterfactual - counter to the fact of what actually happened ] --- exclude: true ## Experiments and models - A common way to do causal inference in many fields is an experiment. - When we’re working with people/firms/countries, running experiments is often infeasible, impossible, or unethical. - So we have to think hard about a model of what the world looks like. - So that we can use our model to figure out what the counterfactual would be. - In causal inference, the model is our idea of what we think the process is that generated the data. - We put together what we know about the world with assumptions we make and end up with our model. -The model can then tell us what kinds of things could give us wrong results so we can fix them and get the right counterfactual. --- exclude: true # Model identification - We have “identified” a causal effect if the estimate that we generate gives us a causal effect. - In other words, when we see the estimate, we can claim that it’s isolating just the causal effect. - Identifying effects requires us to understand the data generating process (DGP). - And once we understand that DGP, knowing what calculations we need to do to isolate our effect.Often these will require taking some conditional values (controls). Or isolating the variation we want in some otherway. - We need to think about how to create models of the processes that generated the data. - Once we have those models, we’ll figure out what methods we can use to generate plausible counterfactuals. - Once we’re really comparing apples to apples, we can figure out, using only data we can actually observe, how things would be different if we reached in and changed X, and how Y would change as a result. --- ## Causal diagrams Causal diagrams were developed in the mid-1990s by the computer scientist Judea Pearl<sup>1</sup> who was trying to develop a way for artificial intelligence to think about causality. </br> .blockquote[ ### Definition: Causal diagram A causal diagram is a graphical representation of a data generating process (DGP). Variables in the DGP are represented by nodes, and the causal relationships in the DGP are depicted by arrows, with each arrow pointing from the cause variable to the effect variable. ] .footnote[ <sup>1</sup> Pearl, Judea. 2009. Causality. 2nd ed. Cambridge, MA: Cambridge University Press. ] --- ## Causal diagrams .blockquote[ ### Example: Flipping coins for cake Two people A and B flip a coin. If they get head, then person A gets a slice of cake. If they get tail, then person B gets the slice. </br> We have... - two variables 1. the outcome of coin flip ( `\(X\)` ) 2. which person gets the cake ( `\(Y\)` ) - one causal relationship: the outcome of the coin flip determines which person gets cake. ] --- ## Causal diagrams .blockquote[ ###Example: Flipping coins for cake <div class="figure"> <img src="data:image/png;base64,#/Users/martin/git_projects/KA_slides/CausalDiagrams/renderthis_139c64790d0ec_files/figure-html/unnamed-chunk-1-1.png" alt="1: A simple causal diagram" width="60%" style="color:black; display:block; margin-right:auto; margin-left:auto; margin-top:15px" /> <p class="caption">1: A simple causal diagram</p> </div> ] --- ## Causal diagrams **Some points to be noted** - Each variable on the graph may take multiple values. - The arrow just tells us that one variable causes another. It does not say anything about whether that causal effect is positive or negative. - Other events that might effect the outcomes are ignored. - Outcomes of outcomes are not taken into consideration. - All (non-trivial) variables relevant to the DGP should be included, even if we cannot measure or see them. --- ## Causal diagrams **Unmeasured Variables** (labelled U) Unmeasured Variables serve two purposes in causal diagrams: - they are key parts of the data generating process - they can sometimes fill in for variables that we know must be there, but we have no idea what they are. **Latent variables** (labelled L) are an example of unmeasured variables: They explain *why* two variables that are correlated but neither of them causes the other --- ## Causal diagrams .blockquote[ ### Example: Ice-cream sales revisited Ice-cream sales (X) are high when people wear shorts (Y). However, there is no causal relationship between ice-cream sales and people wearing sorts: weather (U) is latent variable causes them both. <div class="figure"> <img src="data:image/png;base64,#/Users/martin/git_projects/KA_slides/CausalDiagrams/renderthis_139c64790d0ec_files/figure-html/unnamed-chunk-2-1.png" alt="2: Unobserved variable" width="52%" style="color:black; display:block; margin-right:auto; margin-left:auto; margin-top:15px" /> <p class="caption">2: Unobserved variable</p> </div> ] --- ## Causal diagrams — the real world: on an omission mission <div class="figure"> <img src="data:image/png;base64,#/Users/martin/git_projects/KA_slides/CausalDiagrams/renderthis_139c64790d0ec_files/figure-html/unnamed-chunk-4-1.png" alt="3: Police Presence and Crime Rate by County, North Carolina 1981-1987" width="55%" style="color:black; display:block; margin-right:auto; margin-left:auto; margin-top:5%" /> <p class="caption">3: Police Presence and Crime Rate by County, North Carolina 1981-1987</p> </div> .footnote[ Cornwell, Christopher, and William N. Trumbull. 1994. "Estimating the Economic Model of Crime with Panel Data." The Review of Economics and Statistics 76: 360–66. ] ??? The raw correlation is picking up the fact that high-crime areas get assigned lots of police. --- ## Causal diagrams — the real world: on an omission mission To make a causal diagram, we think of following latent variables: - Expected crime payout (profitability of crime w.r.t. likelihood to get caught, sentencing law severity) - Law and order politics (how tough the political system in the local area wants to be on crime) Some assumptions are: - Lagged crime does not cause law and order politics - The poverty rate is not a part of the DGP - Lagged police per capita does not cause current police per capita - Recent popular crime movies do not cause crime These are arrows that are <u>not</u> there. These are just as important parts of a DAG! It's a balancing act — omitting movies is okay, omitting the poverty rate likely is not! --- ## Causal diagrams — the real world: on an omission mission <div class="figure"> <img src="data:image/png;base64,#/Users/martin/git_projects/KA_slides/CausalDiagrams/renderthis_139c64790d0ec_files/figure-html/unnamed-chunk-5-1.png" alt="4: Police presence and crime rate" style="color:black; display:block; margin-right:auto; margin-left:auto; margin-top:5%" /> <p class="caption">4: Police presence and crime rate</p> </div> --- ## Causal diagrams and research questions **Does additional police presence reduce crime?** The causal diagram can be used to figure out how to identify the answer to our research question. We may identify parts of the diagram that indicate how police per capita to causes crime) - Police per capita → Crime (direct effect) - Expected crime payout → Crime (indirect effect) The variation in our data that answers our research question thus relates to police per capita causing crime, and to police per capita causing expected crime payout, which *then* affects crime. To get our answer, we have to dig out *that* part of the variation in crime and block out the alternative explanations (e.g. lagged crime causes both). --- ## Causal diagrams: Moderators - `\(X\)` → `\(Y\)` and `\(Z\)` → `\(Y\)` - However, this could be consistent with any of the following DGPs 1. `\(Y = .2X + .3Z\)` 2. `\(Y= 2X + 3XZ\)` ...and infinitely many more! - We say that `\(Z\)` has a *moderating influence* on the effect of `\(X\)` on `\(Y\)` in DGP 2 --- ## Causal diagrams: Moderators .vcenter[ .blockquote[ ### Definition: Moderators in causal diagrams Moderators are variables that do not necessarily cause another variable (although they might do that too). Instead, they *moderate the effect of one variable on another*. ]] --- ## Causal diagrams: Moderators **Moderator effects are *not* shown in the causal diagram.** <div class="figure"> <img src="data:image/png;base64,#/Users/martin/git_projects/KA_slides/CausalDiagrams/renderthis_139c64790d0ec_files/figure-html/unnamed-chunk-6-1.png" alt="5: Z moderates X" width="55%" style="color:black; display:block; margin-right:auto; margin-left:auto; margin-top:1%" /> <p class="caption">5: Z moderates X</p> </div> --- ## Causal diagrams: Moderators .vcenter[ .blockquote[ ### Example: Fertility drug Consider the effect of a fertility drug (X) on the chances of getting pregnant (Y). The effect is *moderated* by the variable "having a uterus" (Z). If you don’t have a uterus, the drug cannot do much for you! But if you do have a uterus, it can increase your chances of conceiving. ]]